<?php
namespace Hive\Ressource;
/**
 * Ressource Document Linker Object.
 *
 * It represant a the link between a ressource and a document.
 *
 * @author Xavier VILAIN
 * @package ressource
 * @property int 	$ressource_id	Ressource Id
 * @property string $docid	Linked Document Id
 * @property int 	$cname 			Creator Name
 * @property datetime 	$cdate 			Creation Date
 */
class Document extends \Fox\Object {

	/**
	 * Current Allowed file extensions
	 * @var array
	 */
	public static $ALLOWED_EXTENSIONS = array('doc','txt','pdf','rtf','docx');
	
	/**
	 * Link to Ressource
	 * @var string
	 */
	const LINK_RESSOURCE = 'ressource';

	/**
	 * Link to Document
	 * @var string
	 */
	const LINK_DOCUMENT = 'document';

	/**
	 * Resume Type
	 * @var string
	 */
	const TYPE_RESUME = 'cv';

	/**
	 * (non-PHPdoc)
	 * @see Fox.Object::beforeCreate()
	 */
	protected function beforeCreate() {
		$this->udate = \Fox\Object::sqlDateTime(time());
		$this->uname = \User::current()->getId();
	}
}
\Fox\Dao::infos(Document::className(),new \Fox\Object\Info('ressource_documents', \Fox\Databases::DB_APP));

// Link to Document
\Fox\Object\Links::add(\Fox\Dao::link(Document::className(),Document::LINK_DOCUMENT)
	->to(\Fox\Document::className(), Document::LINK_RESSOURCE)
	->on('docid'));